<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Elasticsearch分词技术深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px;
            border-radius: 12px;
            margin: 20px 0;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
            margin-bottom: 16px;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 30px 0;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fadeInUp">
            <h1 class="text-5xl md:text-6xl font-bold mb-6">
                <i class="fas fa-search mr-4"></i>Elasticsearch分词技术
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">深度解析搜索引擎的核心技术</p>
            <div class="flex justify-center space-x-8 text-lg">
                <div class="flex items-center">
                    <i class="fas fa-clock mr-2"></i>
                    <span>阅读时间：15分钟</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-layer-group mr-2"></i>
                    <span>技术深度：中高级</span>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8 animate-fadeInUp">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-book-open mr-3 text-purple-600"></i>引言
            </h2>
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">在</span>当今信息爆炸的时代，数据的快速增长对信息检索提出了更高的要求。Elasticsearch作为一款强大的分布式搜索和分析引擎，被广泛应用于各种需要全文搜索的场景。而分词在Elasticsearch中扮演着至关重要的角色，它直接影响着搜索的准确性和效率。
            </p>
        </div>

        <!-- Basic Concepts -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8 animate-fadeInUp">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-puzzle-piece mr-3 text-purple-600"></i>分词的基础概念
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8 mt-8">
                <div class="bg-gradient-to-br from-purple-50 to-pink-50 p-6 rounded-lg">
                    <h3 class="text-xl font-bold mb-4 text-gray-800">
                        <i class="fas fa-question-circle mr-2 text-purple-600"></i>什么是分词
                    </h3>
                    <p class="text-gray-700 leading-relaxed">
                        分词是将连续的文本序列按照一定的规则拆分成一个个单独的词语或词元（Term）的过程。在Elasticsearch中，分词是构建倒排索引的前提。
                    </p>
                    <div class="mt-4 p-4 bg-white rounded-lg shadow-sm">
                        <p class="text-sm text-gray-600 mb-2">示例：</p>
                        <p class="font-mono text-purple-700">"Elasticsearch是一款强大的搜索引擎"</p>
                        <p class="text-sm text-gray-600 mt-2">分词结果：</p>
                        <div class="flex flex-wrap gap-2 mt-2">
                            <span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm">Elasticsearch</span>
                            <span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm">是</span>
                            <span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm">一款</span>
                            <span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm">强大</span>
                            <span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm">的</span>
                            <span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm">搜索引擎</span>
                        </div>
                    </div>
                </div>
                
                <div class="bg-gradient-to-br from-blue-50 to-indigo-50 p-6 rounded-lg">
                    <h3 class="text-xl font-bold mb-4 text-gray-800">
                        <i class="fas fa-star mr-2 text-blue-600"></i>分词的重要性
                    </h3>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-blue-600 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-800">提高搜索准确性</h4>
                                <p class="text-gray-600 text-sm mt-1">合理的分词使搜索关键词与文档中的词元更准确地匹配</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-blue-600 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-800">支持复杂搜索功能</h4>
                                <p class="text-gray-600 text-sm mt-1">模糊搜索、短语搜索等高级功能都依赖于分词结果</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Tokenizer Components -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8 animate-fadeInUp">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-cogs mr-3 text-purple-600"></i>Elasticsearch中的分词器
            </h2>
            
            <div class="highlight-box mb-8">
                <h3 class="text-2xl font-bold mb-4">
                    <i class="fas fa-layer-group mr-2"></i>分词器的三大组成部分
                </h3>
                <p class="text-lg opacity-90">Elasticsearch的分词器由字符过滤器、分词器和词元过滤器三部分组成，协同工作完成文本处理。</p>
            </div>

            <!-- Mermaid Diagram -->
            <div class="bg-gray-50 p-6 rounded-lg mb-8">
                <div class="mermaid">
                    graph LR
                        A[原始文本] --> B[字符过滤器]
                        B --> C[分词器]
                        C --> D[词元过滤器]
                        D --> E[最终词元]
                        
                        style A fill:#f9f,stroke:#333,stroke-width:2px
                        style E fill:#9f9,stroke:#333,stroke-width:2px
                        style B fill:#bbf,stroke:#333,stroke-width:2px
                        style C fill:#fbf,stroke:#333,stroke-width:2px
                        style D fill:#ffb,stroke:#333,stroke-width:2px
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-lg shadow-md hover:shadow-xl transition-shadow">
                    <div class="feature-icon">
                        <i class="fas fa-filter"></i>
                    </div>
                    <h4 class="text-xl font-bold mb-3 text-gray-800">字符过滤器</h4>
                    <p class="text-gray-600 mb-3">在分词之前对原始文本进行预处理</p>
                    <ul class="text-sm text-gray-600 space-y-1">
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>去除HTML标签</li>
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>转换大小写</li>
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>字符替换</li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md hover:shadow-xl transition-shadow">
                    <div class="feature-icon">
                        <i class="fas fa-cut"></i>
                    </div>
                    <h4 class="text-xl font-bold mb-3 text-gray-800">分词器</h4>
                    <p class="text-gray-600 mb-3">将文本拆分成词元的核心组件</p>
                    <ul class="text-sm text-gray-600 space-y-1">
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>标准分词器</li>
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>IK分词器</li>
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>自定义分词器</li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md hover:shadow-xl transition-shadow">
                    <div class="feature-icon">
                        <i class="fas fa-magic"></i>
                    </div>
                    <h4 class="text-xl font-bold mb-3 text-gray-800">词元过滤器</h4>
                    <p class="text-gray-600 mb-3">对分词结果进行后处理优化</p>
                    <ul class="text-sm text-gray-600 space-y-1">
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>停用词过滤</li>
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>同义词处理</li>
                        <li><i class="fas fa-angle-right mr-1 text-purple-600"></i>词形还原</li>
                    </ul>
                </div>
            </div>
        